package com.taikang.hmp.hbusiness.diabetes.measure.report.service.impl;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.taikang.hmp.frame.common.datastructre.Dto;
import com.taikang.hmp.frame.common.datastructre.support.BaseDto;
import com.taikang.hmp.frame.common.service.impl.BaseServiceImpl;
import com.taikang.hmp.hbusiness.diabetes.measure.report.service.IReportService;

/** 
 * 报告
 * author:qrp
 * time:2015年12月14日 下午3:33:03
 */
public class ReportServiceImpl extends BaseServiceImpl implements IReportService{

	
	public List<Dto> getReportList(Dto paramDto) {
		int pages = Integer.parseInt(paramDto.getAsString("pages"));
		int start = 0;
		int limit = 10;
		if(pages != 0){
			start = pages * 10;
		}
		
		Dto dto = new BaseDto();
		dto.put("start", start);
		dto.put("limit", limit);
		dto.put("uid", paramDto.getAsString("uid"));
		
		List<Dto> list = null;
		try {
			list = super.getNewDao().queryForPage("report_space.getReportList", dto);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return list;
	}

	
	public boolean setReportState(Dto paramDto) {
		Dto dto = new BaseDto();
		dto.put("id", paramDto.getAsString("id"));
		dto.put("isread", paramDto.getAsString("isread"));
		try {
			super.getNewDao().update("report_space.setReportState", dto);
			return true;
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
	}

	public int getReportCount(Dto paramDto) {
		Dto dto = new BaseDto();
		dto.put("bdate", paramDto.getAsString("bdate"));
		dto.put("edate", paramDto.getAsString("edate"));
		return (Integer)super.getNewDao().queryForObject("report_space.getReportCount", dto);
	}

}
